package inventory.reports.view;

import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.JComboBox;

import java.awt.Dimension;

import javax.swing.JScrollPane;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import common.view.MaterialAdderView;

public class InwardReportView extends JPanel 
{
	private JTextField textFieldFromDate;
	private JTextField textFieldComment;
	private JTable table;
	
	public InwardReportView() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JLabel lblDate = new JLabel("Date :");
		lblDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, lblDate, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblDate, 10, SpringLayout.WEST, this);
		add(lblDate);
		
		textFieldFromDate = new JTextField();
		textFieldFromDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, textFieldFromDate, 0, SpringLayout.NORTH, lblDate);
		springLayout.putConstraint(SpringLayout.WEST, textFieldFromDate, 6, SpringLayout.EAST, lblDate);
		add(textFieldFromDate);
		textFieldFromDate.setColumns(10);
		
		JButton btnFromDate = new JButton("Cl");
		btnFromDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, btnFromDate, 0, SpringLayout.NORTH, lblDate);
		springLayout.putConstraint(SpringLayout.WEST, btnFromDate, 6, SpringLayout.EAST, textFieldFromDate);
		add(btnFromDate);
		
		JLabel lblSupplier = new JLabel("Supplier  :");
		lblSupplier.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, lblSupplier, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblSupplier, 30, SpringLayout.EAST, btnFromDate);
		add(lblSupplier);
		
		JComboBox comboBoxSupplier = new JComboBox();
		comboBoxSupplier.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		comboBoxSupplier.setPreferredSize(new Dimension(200, 20));
		springLayout.putConstraint(SpringLayout.NORTH, comboBoxSupplier, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, comboBoxSupplier, 6, SpringLayout.EAST, lblSupplier);
		add(comboBoxSupplier);
		
		JLabel lblComment = new JLabel("Comment :");
		lblComment.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, lblComment, 25, SpringLayout.SOUTH, lblDate);
		springLayout.putConstraint(SpringLayout.WEST, lblComment, 0, SpringLayout.WEST, lblDate);
		add(lblComment);
		
		textFieldComment = new JTextField();
		textFieldComment.setPreferredSize(new Dimension(500, 20));
		textFieldComment.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, textFieldComment, 0, SpringLayout.NORTH, lblComment);
		springLayout.putConstraint(SpringLayout.WEST, textFieldComment, 7, SpringLayout.EAST, lblComment);
		add(textFieldComment);
		textFieldComment.setColumns(80);
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator, 10, SpringLayout.SOUTH, textFieldComment);
		springLayout.putConstraint(SpringLayout.WEST, separator, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, -10, SpringLayout.EAST, this);
		add(separator);
		
		JButton btnSave = new JButton("Save");
		btnSave.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, btnSave, 200, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, btnSave, -10, SpringLayout.SOUTH, this);
		add(btnSave);
		
		JScrollPane scrollPane = new JScrollPane();
		springLayout.putConstraint(SpringLayout.WEST, scrollPane, 0, SpringLayout.WEST, lblDate);
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPane, -10, SpringLayout.NORTH, btnSave);
		springLayout.putConstraint(SpringLayout.NORTH, scrollPane, 10, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.EAST, scrollPane, -10, SpringLayout.EAST, this);
		add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null},
			},
			new String[] {
				"Sr. No.", "Material Name", "Specification", "Unit", "Quantity", "Price"
			}
		));
		scrollPane.setViewportView(table);
	}

}
